package com.matt.domain.course;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.matt.commons.model.Domain;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Size;
import java.util.Date;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2018/11/22
 * *******************************
 */
@Entity
@Table(name = "course")
@Data
@EqualsAndHashCode(callSuper = true)
public class Course extends Domain{

    @Column(name = "name", columnDefinition = "varchar(50) COMMENT '名称'")
    private String name;

    @Column(columnDefinition = " int DEFAULT 1 COMMENT ' 类型：1，SAT早教课程，2，园区自建，3，公共课程 ，4.培训课程，5直播，6录播' ")
    private Integer type;

    @Column(columnDefinition = "varchar(32) COMMENT '对应模版id'")
    private String typeId;

    @Column(name = "typeName", columnDefinition = "varchar(255) COMMENT '课程类型名称'")
    private String typeName;

//    @Column(name = "typeCode", columnDefinition = "int default 3 COMMENT '课程类型码'")
//    private Integer typeCode;

    @Column(name = "week", columnDefinition = "int default 1 COMMENT '周数对应sat课程'")
    private Integer week;


    @Column(name = "createdId", columnDefinition = "varchar(32) COMMENT '创建人Id'")
    private String createdId;

    @Column(name = "lastModified", columnDefinition = " datetime DEFAULT NOW() COMMENT '最后修改时间' ")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastModified;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date created;

    @Column(name = "lastModifiedId", columnDefinition = "varchar(32) COMMENT '最后修改人Id'")
    private String lastModifiedId;

    @Column(name = "lastModifiedName", columnDefinition = "varchar(50) COMMENT '最后修改人名称'")
    private String lastModifiedName;

    @Column(columnDefinition = "int default 1 COMMENT '模版类型：1,主题课程模版, 2:老的SAT模版, 3通用模板'")
    private Integer templateType = 1;

    @Column(columnDefinition = "varchar(32) COMMENT '对应模版id'")
    private String courseTemplateId;

    @Column(columnDefinition = "varchar(32) COMMENT '园区id'")
    private String areaId;

    private Integer resource;

    @Column(columnDefinition = " int DEFAULT 0 COMMENT ' 状态：0：启用，1：禁用 ' ")
    private Integer status=0;

    @Column(columnDefinition = "varchar(32) COMMENT '创建人id'")
    private String createStaffId;

    @Column(columnDefinition = "varchar(10) COMMENT '创建人名称'")
    private String createStaffName;

    @Column(columnDefinition = "varchar(500) COMMENT '协助人id 多个,隔开'")
    private String helpStaffId;

    @Column(columnDefinition = "varchar(100) COMMENT '协助人名称 多个,隔开'")
    private String helpStaffName;

    @Size(max = 250,message = "课程简介超出长度")
    private String introduction;

    //优先级
    @Column(columnDefinition = " int DEFAULT 0 COMMENT ' 优先级 ' ")
    private Integer priority;

    //视频封面
    private String courseCover;

    @Transient
    private Integer chapterNum;

    /**
     * 视频地址
     */
    private String videoAddress;

    /**
     * 播放量
     */
//    @Column(columnDefinition = " bigint(20) DEFAULT 0 COMMENT '播放量' ")
//    private Long playCount;

    @Column(columnDefinition = " int default 0 COMMENT '播放量' ")
    private Integer playCount;

}
